import Axios from "./axios"  // 导入配置好的axios文件
// 封装axios请求函数，并用export导出
export function axiosPost(apiUrl,datas) {
    return Axios.Axios({
	// url: "/api/getItemList",
	method: "post",
	url: apiUrl,
	headers: {
	    'Content-Type': 'application/x-www-form-urlencoded' //设置请求头请求格式form
	},
	data: datas
    })
}
export function axiosGet(apiUrl,datas) {
    return Axios.Axios({
	method: "get",
	url: apiUrl,
	headers: {
	    'Content-Type': 'application/json'
	},
	params:datas,
    })
}

// 拼接
export function axiosJoint(apiUrl,datas) {
    return Axios.Axios({
	// url: "/api/getItemList",
	method: "post",
	url: apiUrl+datas,
	headers: {
	    'Content-Type': 'application/json' //设置请求头请求格式form
	},
	// data: datas
    })
}
// 请求头'Content-Type': 'application/json'
export function axiosParams(apiUrl,datas) {
    return Axios.Axios({
	method: "post",
	url: apiUrl,
	headers: {
	    'Content-Type': 'application/json;charset=UTF-8' 
	},
	data:JSON.stringify(datas),
	transformRequest: [function (data) {
		// 对 data 进行任意转换处理
		return JSON.stringify(datas);
	  }],
    })
}

export function axiosGetExcel(apiUrl,datas) {
    return Axios.Axios({
	method: "get",
	url: apiUrl,
	headers: {
	    'Content-Type': 'application/octet-stream;charset=utf-8'
	},
	params:datas,
	responseType: 'blob',
    })
}



//上传
export function axiosParamspa(apiUrl,formData) {
    return Axios.Axios({
	method: "post",
	url: apiUrl,
	headers: {
	    'Content-Type': 'application/json,charset=utf-8'
	},
	data:formData, 
	transformRequest: [function (data) {
		// 对 data 进行任意转换处理
		return formData;
	}],
    })
}





